package com.seecen;

import com.seecen.entity.Dept;
import com.seecen.mapper.DeptMapper;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.InputStream;
import java.util.List;

public class Happy1 {
    public static void main(String[] args) throws InterruptedException {
        InputStream is = Happy1.class.getClassLoader().getResourceAsStream("mybatis.xml");
        SqlSessionFactory factory = new SqlSessionFactoryBuilder().build(is);
        SqlSession session = factory.openSession();

        DeptMapper deptMapper = session.getMapper(DeptMapper.class);

        Dept dbDept = deptMapper.findByDeptno(1);
        dbDept.setDname("九江");
        deptMapper.updateDept(dbDept);
        Thread.sleep(20 * 1000);


        session.commit();
        session.close();
    }
}
